package com.ruicar.afs.cloud.apply.admin.manage.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruicar.afs.cloud.apply.admin.manage.entity.SysChannelAuthRegion;
import com.ruicar.afs.cloud.apply.admin.manage.mapper.ApplyChannelAuthRegionMapper;
import com.ruicar.afs.cloud.apply.admin.manage.service.ApplyChannelAuthRegionService;
import com.ruicar.afs.cloud.common.modules.apply.enums.CarTypeEnum;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: Lee
 * @date 2020-06-03 11:19:33
 * @description
 */
@Service
public class ApplyChannelAuthRegionServiceImpl extends ServiceImpl<ApplyChannelAuthRegionMapper, SysChannelAuthRegion> implements ApplyChannelAuthRegionService {

    /**
     * 通过渠道ID和父类ID查询授权区域
     *
     * @param channelId
     * @param businessType
     * @param parentId
     * @return
     */
    public List<SysChannelAuthRegion> getChannelAuthRegionList(Long channelId, CarTypeEnum businessType, String parentId) {

        List<SysChannelAuthRegion> authRegionList = this.baseMapper.selectList(Wrappers.<SysChannelAuthRegion>query().lambda()
                .eq(SysChannelAuthRegion::getChannelId, channelId)
                .eq(SysChannelAuthRegion::getParentId, parentId)
                .eq(SysChannelAuthRegion::getBusinessType, businessType));
        return authRegionList;
    }

}
